
<table width="100%" align="center" border="0">
	<tr>
    <td align="left">
    	<input type="button" value="Add Category" onClick="window.location='index.php?tc=addcat'" >
    </td>
    <td align="center" width="300">
    	<?php if($_REQUEST['_s'] == 2){ ?>
    	<div class="sucmsg"><img src="images/information.png" align="absmiddle" />&nbsp;Deleted Successfully</div>
        <?php } ?>
        </td>
    </tr>
</table>    
<table width="100%" align="center" border="0" class="list">
<thead>
<tr>
	<td align="center" width="50">#</td>
	<td align="center">Category Name</td>
    <td align="center" width="150">Action</td>
</tr>
</thead>
<?php
include('includes/function.php');
$self="index.php?tc=cat";
$rowsPerPage = 20;
$pageNum = 1;
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}
if($_GET['page']=="")
{
	$pageNum = 1;
}

/*<!--counting the offset-->*/
$offset = ($pageNum - 1) * $rowsPerPage;

	$res = mysql_query("select Id from category");
	
	$query = mysql_query("select * from category order by Name limit $offset , $rowsPerPage");
$i = 1;
while($q = mysql_fetch_array($query))
{ 	?>
    <tr>
        <td align="center"><?php echo $i+$offset;?></td>
        <td align="left" style="padding-left:10px;"><?php echo $q["Name"];?></td>
        <td align="center"><a href="index.php?tc=editcat&_d=<?php echo $q['Id'];?>&page=<?php echo $pageNum;?>">Edit</a> | <a href="index.php?tc=editcat&_d=<?php echo $q['Id'];?>&page=<?php echo $pageNum;?>&_a=d" onclick="return confirm('Are you sure want to delete?')">Delete</a></td>
   	</tr>     
<?php 
	$i++;
}
?>
<?php 
if(mysql_num_rows($res) <= $rowsPerPage){	}
else { ?>
<tr>
    <td colspan="7" align="center"  bgcolor="#E3ECF3">
        <?php echo $paginglink=getPagingLink($res, $rowsPerPage,$pageNum,$self); ?>	
    </td>
</tr>
<?php } ?>
</table>    